package com.be.beadmin.service.controller;

import com.be.beadmin.common.utils.ResultModel;
import com.be.beadmin.service.dto.input.SerialNumberItemDto;
import com.be.beadmin.service.dto.input.SerialNumberItemQueryCriteria;
import com.be.beadmin.service.service.SerialNumberItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* @author chenwei
* @date 2023-01-16
**/
@RestController
public class SerialNumberItemController {

    @Autowired
    private  SerialNumberItemService serialNumberItemService;


    @PostMapping(value = "/system/getSerialNumberItemByPage")
    public ResultModel getSerialNumberItemByPage(@RequestBody SerialNumberItemQueryCriteria pageEntity)  {
        return ResultModel.success(serialNumberItemService.getSerialNumberItemByPage(pageEntity)) ;
    }

    @PostMapping("/system/addSerialNumberItem")
    public ResultModel addSerialNumberItem(@RequestBody SerialNumberItemDto serialNumberItemDto){
        serialNumberItemService.addSerialNumberItem(serialNumberItemDto);
        return ResultModel.success(ResultModel.ADD);
    }

    @PostMapping("/system/delSerialNumberItem")
    public ResultModel delSerialNumberItem(@RequestBody SerialNumberItemDto serialNumberItemDto){
        serialNumberItemService.delSerialNumberItem(serialNumberItemDto.getId());
        return ResultModel.success(ResultModel.DELETE);
    }


    @PostMapping("/system/updateSerialNumberItem")
    public ResultModel updateSerialNumberItem(@RequestBody SerialNumberItemDto serialNumberItemDto){
        serialNumberItemService.updateSerialNumberItem(serialNumberItemDto);
        return ResultModel.success(ResultModel.UPDATE);
    }
}